require 'gserver'
require "Network/all"
require "Utilities/all"

module Network
  class BaseServer < GServer
    include Network::PacketData

    def initialize(port, maxConnections = 1, stdlog = $stderr, audit = false, debug = true)
      super(port, maxConnections, stdlog, audit, debug)
    end

    def serve(io)
      @client = io
      @client.drain do |data|
        packets = tokenize(data)
        packets.each { |packet| process packet }
      end
      puts "client disconnected"
    end

    def process(packet)
      puts "processing"
    end
  end
end
